﻿//  2008 by Mario Meir-Huber
// Mail: mario_mh@vb-magazin.de
//       i-mameir@microsoft.com
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ChartLibrary.Base
{
    /// <summary>
    /// Stores information on how the Legend should appear
    /// </summary>
    public class Legend
    {
        private DisplayType _displaytype;   //stores information on the Displaytype
        private Layout _layout;             //stores information on the Layout
        private Brush _foreground;          //stores information on the Forground
        private Brush _background;          //stores information on the Background

        public event StateChangedEvent LegendChanged; //occurs when the legend's position was changed
        public event StateChangedEvent DesignChanged;  //handler to a design changed event

        /// <summary>
        /// This stores information on the legend
        /// </summary>
        public Legend()
        {
            _displaytype = DisplayType.TextAndLine;
            _layout = Layout.Horizontal;
            _foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            _background = new SolidColorBrush(Color.FromArgb(255, 200, 200, 200));
        }

        /// <summary>
        /// Gets the Displaytype for the Chart or sets it
        /// </summary>
        public DisplayType DisplayType 
        {
            get
            {
                return _displaytype;
            }
            set
            {
                _displaytype = value;

                RaiseLegendChanged();
            }
        }

        /// <summary>
        /// Occurs when the Legend was changed
        /// </summary>
        private void RaiseLegendChanged()
        {
            if (null != LegendChanged) LegendChanged();
        }

        /// <summary>
        /// raises a new design changed event
        /// </summary>
        private void RaiseDesignChanged()
        {
            if (null != this.DesignChanged) DesignChanged();
        }

        /// <summary>
        /// Gets the Layout for the Chart or sets it
        /// </summary>
        public Layout Layout
        {
            get
            {
                return _layout;
            }
            set
            {
                _layout = value;

                RaiseLegendChanged();
            }
        }

        /// <summary>
        /// Gets the Forground Brush for the Chart or sets it
        /// </summary>
        public Brush Foreground
        {
            get
            {
                return _foreground;
            }
            set
            {
                _foreground = value;

                RaiseDesignChanged();
            }
        }

        /// <summary>
        /// Gets the Background Brush for the Chart or sets it
        /// </summary>
        public Brush Background
        {
            get
            {
                return _background;
            }
            set
            {
                _background = value;

                RaiseDesignChanged();
            }
        }
    }
}
